<template>
  <el-menu
    default-active="2"
    :collapse="collapsed"
    collapse-transition
    router
    :default-active="$route.path"
    unique-opened
    class="el-menu-vertical-demo"
    background-color="#334157"
    text-color="#fff"
    active-text-color="#ffd04b"
  >
    <div class="logobox">
      <img class="logoimg" src="../assets/img/logo.png" alt="" />
    </div>
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{ menu.menuname }}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item
          v-for="chmenu in menu.menus"
          :index="'/' + chmenu.url"
          :key="chmenu.menuid"
        >
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{ chmenu.menuname }}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
import { menu } from "../api/userMG";
export default {
  name: "leftnav",
  data() {
    return {
      collapsed: false,
      allmenu: [],
    };
  },
  // 创建完毕状态(里面是操作)
  created() {
    let res = {
      success: true,
      data: [
        {
          menuid: 1,
          icon: "icon-mofang",
          menuname: "属性管理",
          url: null,
          menus: [
            {
              menuid: 1 - 1,
              icon: "icon-zujian",
              menuname: "产品类型",
              url: "typeMangent/appTypeMangent",
              menus: null,
            },
            {
              menuid: 1 - 2,
              icon: "icon-baomingbiaodan",
              menuname: "页面类型",
              url: "typeMangent/pageTypeMangent",
              menus: null,
            },
            {
              menuid: 1 - 3,
              icon: "icon-zhishizhuanlan1",
              menuname: "标识管理",
              url: "typeMangent/identificationManagement",
              menus: null,
            },
          ],
        },
        {
          menuid: 2,
          icon: "icon-zidingyimokuai",
          menuname: "产品管理",
          url: null,
          menus: [
            {
              menuid: 2 - 1,
              icon: "icon-zidingyimokuai",
              menuname: "产品管理",
              url: "productMangent/productMangent",
              menus: null,
            },
          ],
        },
        {
          menuid: 3,
          icon: "icon-wangye",
          menuname: "页面管理",
          url: null,
          menus: [
            {
              menuid: 3 - 1,
              icon: "icon-wangye",
              menuname: "页面列表",
              url: "pageMangent/pageList",
              menus: null,
            },
          ],
        },
        {
          menuid: 4,
          icon: "icon-wangye1",
          menuname: "模板管理",
          url: null,
          menus: [
            {
              menuid: 4 - 1,
              icon: "icon-wangye1",
              menuname: "模板列表",
              url: "templateMangent/templateList",
              menus: null,
            },
          ],
        },
        {
          menuid: 5,
          icon: "icon-dianpubijikapian",
          menuname: "链接管理",
          url: null,
          menus: [
            {
              menuid: 5 - 1,
              icon: "icon-dianpubijikapian",
              menuname: "链接类型",
              url: "linkMangent/linkType",
              menus: null,
            },
          ],
        },
        {
          menuid: 6,
          icon: "icon-fuzhukongbai_weixuanzhong",
          menuname: "域名模板",
          url: null,
          menus: [
            {
              menuid: 6 - 1,
              icon: "icon-fuzhukongbai_weixuanzhong",
              menuname: "域名列表",
              url: "domainTemplate/domainList",
              menus: null,
            },
          ],
        },
      ],
      msg: "success",
    };
    this.allmenu = res.data;
    // 监听
    this.$root.Bus.$on("toggle", (value) => {
      this.collapsed = !value;
    });
  },
};
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 40px;
  line-height: 40px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
}
.logoimg {
  height: 40px;
}
</style>
